<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="../bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="../jquery/jquery-3.7.0.min.js"></script>
    <script src="../sidebars/sidebars.js"></script>
    <link href="../sidebars/sidebars.css" rel="stylesheet">
    <script src="../js/common.js"></script>
    <script src="../js/product.js"></script>
    <script src="../js/api/productApi.js"></script>
    <script src="../js/api/categoryApi.js"></script>
    <style>
        html, body {
            height: 100%;
            width: 100%;
        }

        main {
            height: 100%;
        }

        #productImgLabel {
            width: 100px;
            height: 100px;
        }

        #imgMatrix {
            width: 100px;
            height: 100px;
        }

        #imgHeng {
            content: '';
            position: relative;
            margin-left: 25%;
            margin-top: 50%;
            width: 50px;
            height: 2px;
            border-top: solid 1px;
        }

        #imgShu {
            content: '';
            position: relative;
            margin-left: 50%;
            margin-top: -25%;
            width: 2px;
            height: 50px;
            border-left: solid 1px;
        }
    </style>
</head>
<body>
<main class="bg-body-secondary">
    <div class="card mx-2 my-2" style="height: 98%;">
        <div class="border-bottom py-2 bg-body-tertiary">
            <div class="d-flex">
                <div class="text-muted ms-3">
                    展示
                    <div class="mx-2 d-inline-block">
                        <select id="pageSize" class="form-select" aria-label="Default select example"
                                onchange="show(1, this.value)">
                            <option value="5">5</option>
                            <option value="10">10</option>
                            <option value="15" selected>15</option>
                            <option value="20">20</option>
                        </select>
                    </div>
                    页数
                </div>
                <div class="ms-auto text-muted me-3">
                    名称:
                    <div class="ms-2 d-inline-block">
                        <input id="conditionProductName" type="text" class="card" style="width: 80px">
                    </div>
                    分类:
                    <div class="ms-2 d-inline-block">
                        <input id="conditionCategoryName" type="text" class="card" style="width: 80px">
                    </div>
                    <button class="align-middle mx-2 d-inline-block card btn btn-outline-secondary" type="button" onclick="show(undefined, undefined, $('#conditionProductName').val(), $('#conditionCategoryName').val());">搜索
                    </button>
                    <button class="align-middle me-2 d-inline-block card btn btn-outline-secondary" type="button" onclick="deleteProduct()">删除
                    </button>
                    <button type="button" class="align-middle btn btn-primary" data-bs-toggle="modal" data-bs-target="#itemModal" data-bs-type="add"><span class="align-middle me-2 px-0 py-0" style="font-weight: 1000; font-size: 20px">+</span><span class="align-middle">新增商品</span></button>
                </div>
            </div>
        </div>
        <div class="table-responsive" style="min-height: 180px; height: 90%">
            <table class="table card-table table-vcenter text-nowrap datatable">
                <thead>
                <tr>
                    <th class="w-1"><input id="checkHead" class="form-check-input m-0 align-middle" type="checkbox"
                                           aria-label="Select all invoices" onchange="setCheckAll(this)"></th>
                    <th class="w-1"><span class="d-flex justify-content-center">id</span></th>
                    <th scope="col"><span class="d-flex justify-content-center">商品名称</span></th>
                    <th scope="col"><span class="d-flex justify-content-center">商品库存</span></th>
                    <th scope="col"><span class="d-flex justify-content-center">商品描述</span></th>
                    <th scope="col"><span class="d-flex justify-content-center">商品分类</span></th>
                    <th scope="col"><span class="d-flex justify-content-center">商品图片</span></th>
                    <th scope="col"><span class="d-flex justify-content-center">商品价格</span></th>
                    <th scope="col"><span class="d-flex justify-content-center"></span></th>

                </tr>
                </thead>
                <tbody id="tbody" style="height: 20%">
                <tr>
                    <td><input class="form-check-input m-0 align-middle" type="checkbox"
                               aria-label="Select invoice"></td>
                    <td><span class="d-flex justify-content-center">1</span></td>
                    <td><span class="d-flex justify-content-center">jackson</span></td>
                    <td><span class="d-flex justify-content-center">jackson</span></td>
                    <td><span class="d-flex justify-content-center">jackson</span></td>
                    <td><span class="d-flex justify-content-center">jackson</span></td>
                    <td><span class="d-flex justify-content-center">1243252341</span></td>
                    <td><span class="d-flex justify-content-center">2322-12-32</span></td>
                    <td><span class="d-flex justify-content-center">2322-12-32</span></td>
                    <td class="text-end">
                        <div class="d-flex justify-content-center">
                                <span class="dropdown">
                                  <button class="btn dropdown-toggle" data-bs-boundary="viewport"
                                          data-bs-toggle="dropdown">操作</button>
                                    <ul class="dropdown-menu dropdown-menu-start"
                                        style="min-width: 1px;">
                                        <li>
                                            <button class="dropdown-item" type="button">编辑</button>
                                        </li>
                                        <li>
                                            <button class="dropdown-item" type="button">删除</button>
                                        </li>
                                    </ul>
                                </span>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>
        <div class="card-footer d-flex align-items-center bg-body-tertiary">
            <p class="m-0 text-muted">展示 <span id="sumPage">16</span> 条数据中的 <span id="startPage">1</span> 到 <span
                    id="endPage">8</span> 条</p>
            <ul id="pageLink" class="pagination m-0 ms-auto">
            </ul>
            <p class="text-muted m-0 align-middle ms-3">前往<input class="card d-inline-block" style="width: 50px; text-align:center" type="text" onchange="productPageItem(this)">页</p>
        </div>
    </div>
</main>

<div class="modal fade" id="itemModal" tabindex="-1" aria-labelledby="itemModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <h1 id="modalTitle" class="modal-title fs-5" id="exampleModalLabel">商品</h1>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
            </div>
            <div class="modal-body">
                <form id="product_form">
                    <div class="mb-3">
                        <input id="product_id" style="display: none">
                        <label for="product_code" class="col-form-label">编码:</label>
                        <input type="text" class="form-control" id="product_code">
                    </div>
                    <div class="mb-3">
                        <label for="product_title" class="col-form-label">名称:</label>
                        <input type="text" class="form-control" id="product_title">
                    </div>
                    <div class="mb-4" style="height: 100px">
                        <label for="product_categoryId" class="col-form-label" style="display: block">分类:</label>
                        <h6 style="float:left;margin-top: 30px">页数:</h6>
                        <select title="页数" class="form-select" size="3" id="product_category_page"
                                style="width: 20%;float: left;margin-left: 15px;margin-right: 25px">
                        </select>
                        <h6 style="float: left;margin-top: 30px">类型:</h6>
                        <select title="类型" class="form-control" id="product_categoryId"
                                style="width: 20%; float: left;margin-top: 20px;margin-left: 15px;">
                        </select>
                    </div>
                    <div class="mb-3">
                        <div class="mb-2" style="">图片:</div>
                        <label id="productImgLabel" for="product_img_file" class="col-form-label">
                            <div id="imgMatrix" class="border border-dark">
                                <div id="imgHeng"></div>
                                <div id="imgShu"></div>
                            </div>
                        </label>
                        <input type="file" class="" id="product_img_file" style="display: none">
                    </div>
                    <div class="mb-3">
                        <label for="product_price" class="col-form-label">价格:</label>
                        <input type="number" class="form-control" id="product_price">
                    </div>
                    <div class="mb-3">
                        <label for="product_stocks" class="col-form-label">库存:</label>
                        <input type="number" class="form-control" id="product_stocks">
                    </div>
                    <div class="mb-3">
                        <label for="product_description" class="col-form-label">描述:</label>
                        <textarea type="text" class="form-control" id="product_description"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" onclick="resetProduct_form()" class="btn btn-info">清空</button>
                <button id="product_modal_close" type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消
                </button>
                <button id="product_modal_submit" type="button" class="btn btn-primary">Send message</button>
            </div>
        </div>
    </div>
</div>

</body>
<script>
    $(function () {
        initProduct();
    })
</script>
</script>
</html>